home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bdiritem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  3.9 KB  |  156 lines

  1. /* 
  2.  *
  3.  * $Id: k3bdiritem.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BDIRITEM_H
  18. #define K3BDIRITEM_H
  19.  
  20.  
  21. #include <qstring.h>
  22. #include <qptrlist.h>
  23.  
  24. #include <kio/global.h>
  25.  
  26. #include "k3bdataitem.h"
  27. #include "k3b_export.h"
  28. class K3bDataDoc;
  29.  
  30. /**
  31.  *@author Sebastian Trueg
  32.  */
  33.  
  34. class LIBK3B_EXPORT K3bDirItem : public K3bDataItem
  35. {
  36.  public: 
  37.   K3bDirItem( const QString& name, K3bDataDoc*, K3bDirItem* parentDir = 0 );
  38.  
  39.   /**
  40.    * Default copy constructor. Copies the dir including all children. However, none of the
  41.    * children will have set a doc and the copy dir will not have set a parent dir.
  42.    */
  43.   K3bDirItem( const K3bDirItem& );
  44.  
  45.   virtual ~K3bDirItem();
  46.  
  47.   K3bDataItem* copy() const;
  48.     
  49.   K3bDirItem* getDirItem() const;
  50.  
  51.   const QPtrList<K3bDataItem>& children() const { return m_children; }
  52.   K3bDirItem* addDataItem( K3bDataItem* item );
  53.   K3bDataItem* takeDataItem( K3bDataItem* item );
  54.     
  55.   K3bDataItem* nextSibling() const;
  56.   K3bDataItem* nextChild( K3bDataItem* ) const;
  57.  
  58.   bool alreadyInDirectory( const QString& fileName ) const;
  59.   K3bDataItem* find( const QString& filename ) const;
  60.   K3bDataItem* findByPath( const QString& );
  61.  
  62.   long numFiles() const;
  63.   long numDirs() const;
  64.  
  65.   bool isEmpty() const { return ( numDirs() + numFiles() == 0 ); }
  66.  
  67.   /**
  68.    * returns true if item is a subItem of 
  69.    * this dir item 
  70.    * (returns also true if item == this
  71.    */
  72.   bool isSubItem( K3bDataItem* item ) const;
  73.  
  74.   bool isDir() const { return true; }
  75.  
  76.   virtual bool isRemoveable() const;
  77.  
  78.   /**
  79.    * \return true if some child is from an old session.
  80.    */
  81.   virtual bool isFromOldSession() const;
  82.  
  83.   /**
  84.    * Recursively creates a directory.
  85.    */
  86.   bool mkdir( const QString& dir );
  87.  
  88.   void setLocalPath( const QString& p ) { m_localPath = p; }
  89.   QString localPath() const { return m_localPath; }
  90.  
  91.   /**
  92.    * \reimplemented
  93.    */
  94.   bool writeToCd() const;
  95.  
  96.  protected:
  97.   /**
  98.    * Normally one does not use this method but K3bDataItem::size()
  99.    *
  100.    * This method does not take into account the possibility to share the data
  101.    * between files with the same inode in an iso9660 filesystem.
  102.    * For that one has to use K3bFileCompilationSizeHandler.
  103.    */
  104.   KIO::filesize_t itemSize( bool followSymlinks ) const;
  105.  
  106.   /*
  107.    * Normally one does not use this method but K3bDataItem::blocks()
  108.    */
  109.   K3b::Msf itemBlocks( bool followSymlinks ) const;
  110.  
  111.  private:
  112.   /**
  113.    * this recursivly updates the size of the directories.
  114.    * The size of this dir and the parent dir is updated.
  115.    * These values are just used for user information.
  116.    */
  117.   void updateSize( K3bDataItem*, bool removed = false );
  118.   /**
  119.    * Updates the number of files and directories. These values are
  120.    * just used for user information.
  121.    */
  122.   void updateFiles( long files, long dirs );
  123.  
  124.   mutable QPtrList<K3bDataItem> m_children;
  125.  
  126.   // size of the items simply added
  127.   KIO::filesize_t m_size;
  128.   KIO::filesize_t m_followSymlinksSize;
  129.  
  130.   // number of blocks (2048 bytes) used by all the items
  131.   long m_blocks;
  132.   long m_followSymlinksBlocks;
  133.  
  134.   long m_files;
  135.   long m_dirs;
  136.  
  137.   // HACK: store the original path to be able to use it's permissions
  138.   //        â”¤remove this once we have a backup project
  139.   QString m_localPath;
  140. };
  141.  
  142.  
  143. class K3bRootItem : public K3bDirItem
  144. {
  145.  public:
  146.   K3bRootItem( K3bDataDoc* );
  147.   ~K3bRootItem();
  148.  
  149.   const QString& k3bName() const;
  150.   void setK3bName( const QString& );
  151.  
  152.   bool isMoveable() const { return false; }
  153.   bool isRemoveable() const { return false; }
  154. };
  155. #endif
  156.